﻿using System;
using System.Linq;
class Program
    {
        static void Main(string[] args)
        {
            Random rand = new Random();
            int[] nums = new int[100];
            for (int i = 0; i < 100; i++)
                nums[i] = rand.Next(0, 1001);
            var sortedNum = from num in nums
                            orderby num descending
                            select num;
            nums = sortedNum.ToArray<int>();
            Console.WriteLine("降序排列:");
            for (int i = 0; i < 10; i++)
            {
                for (int j = 0; j < 10; j++)
                    Console.Write("{0}\t", nums[i * 10 + j]);
                Console.WriteLine();
            }
            int sum = sortedNum.Sum(n => n);
            double avg = sortedNum.Average(n => n);
            Console.WriteLine("总和为 "+ sum);
            Console.WriteLine("平均数为 "+ avg);
        }
    }
